package com.grape.springbootgradle20220520.web;

import com.lkx.util.ExcelUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

@RestController
//@Controller
@RequestMapping("/excel")
public class ExcelController {

    @GetMapping("/export")
    public void export(HttpServletResponse response) throws Exception {
        List<Person> list = Arrays.asList(new Person("robin", 11), new Person("tome", 12), new Person("lucy", 13));
        ExcelUtil.exportExcelOutputStream(response, list, Person.class, "名单");
    }

    @GetMapping("/version")
    public String version(){
        return "3.1.0";
    }
}

